<template>
	<view>
		<view class="header">
			<image class="header-image" src="http://hkb.zanboon.com/background.png" mode="widthFix"></image>
			<view class="header-title">
				恭喜你，锁定学位成功，获的福利！
			</view>
			<view class="header-text">
				学位紧张,请尽快联系老师,付款确定学位！
			</view>
			<view class="header-time">
				<view><span>{{h}}</span></view>
				<span>分</span>
				<view><span>{{m}}</span></view>
				<span>秒</span>
				<view><span>{{s}}</span></view>
				<span>”</span>
			</view>
			<view class="header-tips">温馨提示：10分钟未完成付款，锁定学位将被取消</view>
		</view>
		<view class="body">
			<view>购课专属福利</view>
			<image v-if="online_courses && online_courses.img" :src="online_courses.img" mode="widthFix"></image>
			<!-- <image v-else src="http://hkb.zanboon.com/online_courses_img.png" mode="widthFix"></image> -->
		</view>
		<view class="foot">
			<view style="margin-top: 400rpx 0;padding-left: 50rpx;">
				<swiper class="swiper" 
						circular="true"
						vertical="true"
						disable-touch="true"
						autoplay="true" 
						interval="2000" 
						duration="1500"
						style="width: 100%;height: 75rpx;display: inline-block;vertical-align: middle;">
						<swiper-item v-for="(item , index) in homeSlide" :key="index">
							<image style="display: inline-block;vertical-align: middle;width: 70rpx;border-radius: 50%;"  mode="widthFix" :src="item.avatar"></image>
							<text style="display: inline-block;font-size: 30rpx;margin-left: 15rpx;">{{item.nickname}} 已领取成功</text>
						</swiper-item>
				</swiper>
				<!-- <text style="font-size: 28rpx;">已经购课成功</text> -->
			</view>
		</view>
		<view class="btn">
			<view v-if="online_courses && online_courses.pay_link" @click="tolink(online_courses.pay_link)">立刻领取福利</view>
			<view v-else @click="tolink('')">立刻领取福利</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				h:9,//时
				m:59,//分
				s:99,//秒
				countdown:'24:00:00',//倒计时
				timer:null,//重复执行
				homeSlide: [
					{
						avatar:"https://thirdwx.qlogo.cn/mmopen/vi_32/iaamjiay2e3eDkh03lJsYCh6Yn052L8pk8MYyl3TkIuqG4z5BhNLEb56cibK21fkq4ibwG0HnpDn846QMuS8SbNgvg/132",
						nickname:"张三"
					},
					{
						avatar:"https://thirdwx.qlogo.cn/mmopen/vi_32/iaamjiay2e3eDkh03lJsYCh6Yn052L8pk8MYyl3TkIuqG4z5BhNLEb56cibK21fkq4ibwG0HnpDn846QMuS8SbNgvg/132",
						nickname:"李四"
					},
					{
						avatar:"https://thirdwx.qlogo.cn/mmopen/vi_32/iaamjiay2e3eDkh03lJsYCh6Yn052L8pk8MYyl3TkIuqG4z5BhNLEb56cibK21fkq4ibwG0HnpDn846QMuS8SbNgvg/132",
						nickname:"王五"
					}
				],
				activity_id:"",
				online_courses:"",
			}
		},
		onLoad(option){
			console.log("sub",option)
			this.timer = setInterval(()=>{
			   this.timeCount()
			},10)
			
				let activity_id = option.activity_id
				this.activity_id = option.activity_id	
				this.$api.queryByActivity({activity_id}).then(res => {
				console.log("ccvv",res)
				this.homeSlide = res.list
				this.getOnlineCoursesByActivityId()
			})
		},
		methods: {
			tolink(url){
				location.href = url
			},
			getOnlineCoursesByActivityId(){
				let activity_id = this.activity_id
				this.$api.getOnlineCoursesByActivityId({activity_id}).then(res => {
					console.log("getOnlineCoursesByActivityId",res)
					if(res.status){
						this.online_courses = res.data
						uni.setNavigationBarTitle({
						　　title:res.activity_name
						})
						console.log(this,"vvnnnnnn")
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			timeCount(){
				if(this.s==0 && this.m==0 && this.h==0){
					clearInterval(this.timer)
					return false
				}
				--this.s;
				if(this.s<0){
					--this.m;
					this.s=99;
				}
				if(this.m<0){
					--this.h;
					this.m=59
				}
				if(this.h<0){
					this.s=0;
					this.m=0;
				}
				this.countdown = this.h+":"+this.m+":"+this.s
			},
		}
	}
</script>
	
<style>
.header{
	/* border: 1rpx #000000 solid; */
	padding: 0;
	/* position: relative; */
	/* overflow:; */
}

.header-image{
	width: 100%;
	position: absolute;top: 0;left: 0;
	z-index: -1;
	
}

.header-title{
	/* border: 1rpx #000000 solid; */
	font-size: 35rpx;
	text-align: center;
	color: #FFF5EE;
}

.header-title span{
	/* border: 1rpx #000000 solid; */
	display: block;
	font-size: 75rpx;
}

.header-text{
	/* border: 1rpx #000000 solid; */
	font-size: 26rpx;
	text-align: center;
	color: #FFF5EE;
	padding: 5rpx 0;
}

.header-time{
	/* border: 1rpx #000000 solid; */
	text-align: center;
	padding: 20rpx 0;
	/* height: 120px; */
	/* height: 140px; */
	/* line-height: 10px; */
}
.header-time view{
	border: 1rpx #000000 solid;
	display: inline-block;
	width: 60rpx;
	height: 60rpx;
	margin: 0 10rpx;
	border-radius: 15rpx;
	background-color: #A0522D;
}
.header-time span{
	/* border: 1rpx #000000 solid; */
	position: relative;
	top: 0rpx;
	font-size: 35rpx;
	color: #FFFF00;
	/* vertical-align:middle */
}
.header-tips{
	text-align: center;
	font-size: 22rpx;
	color: #FFFF00;
}
.body{
	/* border: 1rpx #000000 solid; */
	background-color: #ffffff;
	margin: 0 20rpx;
	text-align: center;
	border-radius: 20rpx;
	padding: 0 40rpx;
	
}
.body view{
	font-size: 40rpx;
	/* border: 1rpx #000000 solid; */
	text-align: center;
	margin-bottom: 20rpx;
	/* font-weight: 500; */
	/* padding: 20rpx; */
}
.body image{
	width: 100%;
	/* padding: 20rpx; */
	border-radius: 15rpx;
}
.foot{
	/* border: 1rpx #000000 solid; */
	margin-bottom: 200rpx;
	/* background-color: #000000; */
}
.btn{
	/* border: 1rpx #000000 solid; */
	text-align: center;
	margin: 50rpx 0;
	position: fixed;
	bottom: 0;
	width: 100%;
	z-index: 10;
}
.btn view{
	/* border: 1rpx #000000 solid; */
	display: inline-block;
	width: 80%;
	font-size: 43rpx;
	padding: 15rpx 0;
	background-color: #FF6347;
	border-radius: 50rpx;
	color: #ffffff;
}
</style>
